# coding: utf-8
'''
Created on 2015��5��4��

@author: luyi
'''
import random
import time
import os

def makeDirs(path):
    if not os.path.exists(os.path.dirname(path)):
        os.makedirs(os.path.dirname(path))
        
if __name__ == '__main__':
    roleNameSuffix = '_乄傷城ゞ、'
    dString = '0123456789'
    fileTime = time.strftime('%Y%m%d%H%M', time.localtime(time.time()))
    curtime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
    groupids = [ '9' + str(x).rjust(3,'0') for x in range(1,208) ]
    confFile = "D:\\home\\etl\\dbdata\\inc\\info\\inc_qd_%s.lst" % fileTime 
    makeDirs(confFile)   
    
    cf =  open(confFile,'wb')

    for groupId in groupids:
        outFile = "D:\\home\\etl\\dbdata\\inc\\data/inc_%s_%s.txt" %(groupId.strip(), str(fileTime).strip())
        makeDirs(outFile)
        if not os.path.exists(os.path.dirname(outFile)):
            os.makedirs(os.path.dirname(outFile))
        
        of = open(outFile,'w')
        
        for i in xrange(2300): 
            cnmaster = ''.join(random.sample(dString, 9))
            roleguid_h = cnmaster[:-2] + cnmaster[:2]
            roleguid_l = cnmaster[:-3] + cnmaster[:3]
            role_name = cnmaster + roleNameSuffix
            role_level = ''.join(random.sample(dString, 2))
            logtime = str(curtime)
            # groupid = int(groupId)
            fields = [cnmaster,roleguid_h,roleguid_l,role_name,role_level,logtime]
            of.write('\t'.join(fields) + '\n')
        record = str(groupId) + '\t' + str(fileTime) + '\t' + "OK" + '\n'
        cf.write(record)
        of.close()
        
    cf.close()
